import { toSuccess, useRedis } from "@sker/core"
import { useData } from "@sker/runtime"
import { z } from "zod"


export default async () => {
    const input = z.object({
        uuid: z.string()
    })
    const body = input.parse(useData())
    await useRedis(8, async r => {
        const key = `red.${body.uuid}`
        await r.del(key)
    })
    await useRedis(7, async (r)=>{
        const lockDeviceKey = `lock.device.${body.uuid}.*`;
        const keys = await r.keys(lockDeviceKey)
        await Promise.all(keys.map(async key=>await r.del(key)))
    })
    return toSuccess(true)
}
